	  <?php form_head("admin/teacher_request".$type_id,"");
       $user = $this->user->get();
	  ?>
          <?php text_field("name","ชื่อผู้ขอเบิกจ่าย",array("name" =>$user["firstname"]." ".$user["lastname"]),"disable"); ?>
         
            <?php area_field("detail","รายละเอียดขอเบิกจ่าย",null,1); ?>
            
            <?php 

		 $rows =  $this->db->query("select place_id,  place_name from  place")->result_array();

		 select_field("place_id","ห้องปฎิบัติการ/สถานที่",$rows,"place_name","โปรดเลือก",0,null,"",2); 

		//select_field($name,$label,$rows,$label_value,$row,$cleaner = 0,$first_label="โปรดเลือก",$class ="",$type=1)

		 ?>
         <?php 
		 $rows =  $this->db->get("meterial_base_categories")->result_array();
 ?>
 

   
  </form>
          
   <table class="list list-form" style="width:750px;">
   <thead>
   
          
            <th style="width: 150px;">หมวดวัสดุครุภัณพ์</th>
            
             <th style="width: 40px;">จำนวน</th>
              <th style="width: 200px;">รายละเอียด/หมาเหตุ</th>
             
            <th></th>
           
         
   </thead>
          <tbody id="items">
                 
              <tr>
              <td><?php $this->p->category_options(1,$type_id); ?> </td>
           <td><input id="amount" style="width: 40px;" name="amount" class="amount" value="<?php echo set_value("amount","1"); ?>" type="text" /></td>
           <td><input id="remark" name="remark" class="remark" value="<?php echo set_value("remark"); ?>" type="text" /></td>
           	
            <td><input class="submit" type="button" onclick="add_item();" value="เพิ่มรายการ" /></td>
              </tr>
        
                  </tbody></table>
 <div onclick="javascript:document.forms['myform'].submit();" class="btimg">บันทึก</div>                 
 <script type="text/javascript">

 $(document).ready(function() {


	 $.ajax({
		  type: "POST",
		  url: "<?php echo site_url("service/teacher_request_item"); ?>/view",
		  data: "",
		  success: function(data) {
			  $('#items').html(data);
	 	}
		});
	 
	});

 
function add_item()
{
 var category_id = $("#category_id").val();
 var amount = $("#amount").val();
 var remark = $("#remark").val();
 $.ajax({
	  type: "POST",
	  url: "<?php echo site_url("service/teacher_request_item"); ?>/insert",
	  data: "category_id="+category_id+"&amount="+amount+"&remark="+remark,
	  success: function(data) {
		  $('#items').html(data);
 	}
	});

}
function remove_item(id)
{
	
	 $.ajax({
		  type: "POST",
		  url: "<?php echo site_url("service/teacher_request_item"); ?>/delete",
		  data: "category_id="+id,
		  success: function(data) {
			  $('#items').html(data);
	 	}
		});
}
 </script>

